package com.example.demo.service;

import com.example.demo.entity.Comment;
import com.example.demo.mapper.CommentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommentService  {
    @Autowired
    CommentMapper commentMapper;

    public List<Comment> selectCommentAll() {
        return commentMapper.findAll();
    }

    public List<Comment> selectByAId(Integer aId) {
        return commentMapper.selectByAId(aId);
    }

    public void addComment(String author, String content,Integer aId) {
        Comment comment = new Comment();
        comment.setAuthor(author);
        comment.setContent(content);
        comment.setAId(aId);
        commentMapper.save(comment);
    }

}
